# -coding:utf-8 -*-
"""
日期转换相关操作函数
"""
import datetime
from EmQuantAPI import *

def date_format_convert(date=None):
    """
    日期：2021/3/8 转换成 2021-03-08
    TODO :设置默认值
    """

    df = datetime.datetime.strptime(date, "%Y/%m/%d").date()
    date = datetime.datetime.strftime(df, "%Y-%m-%d")

    return date


def get_current_date() -> "str:date-返回当前日期":

    return ""



def getDateOfCycle(start_date=None, end_date=None):
    """
    获取日期范围内的 股票交易周期数
    返回日期列表
    """
    if start_date is None:
        start_date = "2020-01-01"
    if end_date is None:
        end_date = datetime.datetime.now().strftime('%Y-%m-%d')
    # 2021-03-14 10:06:37
    data = c.tradedates(start_date, end_date, "period=1,order=2,market=CNSESH")
    traddate_list = data.Data
    return traddate_list

if __name__ == "__main__":
    date = date_format_convert("2021/3/8")
    print(date)
